export GEM_HOME="$HOME/.gem" # then run your gem install ...
sudo gem install -n /usr/local/bin cocoapods